package net.zz.base.validate.constraintvalidators;


import net.zz.base.validate.ann.QQ;
import net.zz.base.validate.plug.Regx;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;


/**
 * Created by ZaoSheng on 2015/5/9.
 */
public class QQValidator implements ConstraintValidator<QQ, String> {
    private String message;
    private int errorCode;

    public void initialize(QQ annotation) {
        this.message = annotation.message();
        this.errorCode = annotation.erroCode();

    }

    public boolean isValid(String value, ConstraintValidatorContext context) {

        if (null == value || value.matches(Regx.QQ) || value.matches(Regx.PHONE))
        {
            return true;
        }
        return false;

    }
}
